package com.example.myapplication;

import android.content.Context;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.HashMap;
import java.util.Map;

public class zzzzz2025103102FileSaveQQ_inner {
    public static boolean saveUserInfo(Context context, String number, String password) {
        try {
            FileOutputStream fos = context.openFileOutput("data1.txt", Context.MODE_PRIVATE);
            fos.write((number + ":" + password).getBytes());
            fos.close();
            return true;
        }catch (Exception e){
            e.printStackTrace();
            return false;
        }
    }
    //从data.txt文件中获取存储的qq账号和密码
    public static Map<String, String> getUserInfo(Context context) {
        String content ="";
        try {
            FileInputStream fis = context.openFileInput("data1.txt");
            byte[] buffer = new byte[fis.available()];
            fis.read(buffer);
            content = new String(buffer);
            Map<String, String> userMap = new HashMap<>();
            String[] userInfo = content.split(":");
            userMap.put("account", userInfo[0]);
            userMap.put("password", userInfo[1]);
            fis.close();
            return userMap;
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }
}
